package com.ksm.zyz.controller;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ksm.zyz.common.base.BaseController;
import com.ksm.zyz.sys.entity.BaseShopInfo;
import com.ksm.zyz.sys.entity.BsData;
import com.ksm.zyz.sys.entity.ExtData;
import com.ksm.zyz.sys.serverentity.sBaseShopInfo;
import com.ksm.zyz.sys.serverservice.sBaseShopInfoService;
import com.ksm.zyz.sys.service.baseShopInfoService;

/**
 * @author liuhao
 *
 */
@Controller
@RequestMapping("BaseShopInfoTongBu")
public class BaseShopInfoController extends BaseController<sBaseShopInfo> {

	@Autowired
	private sBaseShopInfoService sService;
	@Autowired
	private baseShopInfoService Service;



	   @RequestMapping(value ="BaseShopInfo")
	    @ResponseBody
		public ExtData BaseShopInfo(int ming, HttpServletRequest req){
	         //List<sOrderMemberInfo> list=sMemberService.selectSome();
		   int scount=(int)sService.selectAllCount();
		   int count=(int)Service.selectCount(ming);
		   int begin=0;
		   if(scount>count)
		   {			   
			   begin=count;
		   }
		   else{
			   extData.setTotalCount(0);
			   return extData;
		   }
		   System.out.println(count+"总数据量");
		   sBaseShopInfo sInfo =new sBaseShopInfo();
		   BsData bsdata=new BsData();
		   bsdata.setBegin(begin);
		   bsdata.setLimit(scount);
		   sInfo.setBsData(bsdata);
		   List<BaseShopInfo> list=sService.selectAllInfo(sInfo);
		   for(int j=0;j<list.size();j++)
		   {
			   BaseShopInfo info=list.get(j);
			   System.out.println(list.get(j).getShopName());
			   info.setSmId(ming);	
			   Service.insertSelective(info);
			 /* try
			   {
				   Service.insertSelective(info);					   
			   }
			   catch(Exception e){
				   System.out.println(info.getId()+"@@@@@");
				   extData.setTotalCount(j);
				   return extData;   
			   }*/
			   
		   }
			     			   
		   extData.setTotalCount(scount-count);	
	               
			return extData;    
		}
	  
	   

}
